﻿using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;

namespace Utility
{
	public class XMLProcessing
	{
		// Check xml file and its Schema
		// If 

		public XMLProcessing()
		{

		}

		public bool ValidateXML(string xmlContent, string xmlSchema)
		{
			XDocument xmlDocObj = XDocument.Load(xmlContent);
			XmlSchemaSet xmlSchemaObj = new XmlSchemaSet();
			xmlSchemaObj.Add("", XmlReader.Create(new StringReader(xmlSchema)));

			return ValidateXML( xmlDocObj, xmlSchemaObj);
		}

		public bool ValidateXML(XDocument xmlDocObj, XmlSchemaSet xmlSchemaObj)
		{
			bool bResult = false;
			xmlDocObj.Validate(xmlSchemaObj, (o, e) => bResult = true);

			return bResult;
		}

		//create 
		public bool CreateXMLAgainstSchema(XmlSchemaSet xmlSchemaObj)
		{
			bool bResult = false;


			return bResult;
		}
	}
}
